<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>  
<c:set var="user" value="${sessionScope.user.userName}" scope="page" ></c:set>
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta charset="utf-8" />
		<title>Tables - Ace Admin</title>

		<meta name="description" content="Static &amp; Dynamic Tables" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />

		


		<!-- bootstrap & fontawesome -->
		<link rel="stylesheet" href="<%=request.getContextPath()%>/static/assets/css/bootstrap.min.css" />
		<link rel="stylesheet" href="<%=request.getContextPath()%>/static/assets/css/font-awesome.min.css" />

		<!-- page specific plugin styles -->

		<!-- text fonts -->
		<link rel="stylesheet" href="<%=request.getContextPath()%>/static/assets/css/ace-fonts.css" />

		<!-- ace styles -->
		<link rel="stylesheet" href="<%=request.getContextPath()%>/static/assets/css/ace.min.css" id="main-ace-style" />

		<!--[if lte IE 9]>
			<link rel="stylesheet" href="<%=request.getContextPath()%>/static/assets/css/ace-part2.min.css" />
		<![endif]-->
		<link rel="stylesheet" href="<%=request.getContextPath()%>/static/assets/css/ace-skins.min.css" />
		<link rel="stylesheet" href="<%=request.getContextPath()%>/static/assets/css/ace-rtl.min.css" />

		<!--[if lte IE 9]>
		  <link rel="stylesheet" href="<%=request.getContextPath()%>/static/assets/css/ace-ie.min.css" />
		<![endif]-->

		<!-- inline styles related to this page -->

		<!-- ace settings handler -->
		<script src="<%=request.getContextPath()%>/static/assets/js/ace-extra.min.js"></script>

		<!-- HTML5shiv and Respond.js for IE8 to support HTML5 elements and media queries -->

		<!--[if lte IE 8]>
		<script src="<%=request.getContextPath()%>/static/assets/js/html5shiv.min.js"></script>
		<script src="<%=request.getContextPath()%>/static/assets/js/respond.min.js"></script>
		<![endif]-->
		
		<!-- the following scripts are used in demo only for onpage help and you don't need them -->
		<link rel="stylesheet" href="<%=request.getContextPath()%>/static/assets/css/ace.onpage-help.css" />
		<link rel="stylesheet" href="<%=request.getContextPath()%>/static/docs/assets/js/themes/sunburst.css" />
		
	
		
	</head>

	<body class="no-skin">
		<!-- #section:basics/navbar.layout -->
		<div id="navbar" class="navbar navbar-default">
			<script type="text/javascript">
				try{ace.settings.check('navbar' , 'fixed')}catch(e){}
			</script>

			<div class="navbar-container" id="navbar-container">
				<!-- #section:basics/sidebar.mobile.toggle -->
				<button type="button" class="navbar-toggle menu-toggler pull-left" id="menu-toggler">
					<span class="sr-only">Toggle sidebar</span>

					<span class="icon-bar"></span>

					<span class="icon-bar"></span>

					<span class="icon-bar"></span>
				</button>

				<!-- /section:basics/sidebar.mobile.toggle -->
				<div class="navbar-header pull-left">
					<!-- #section:basics/navbar.layout.brand -->
					<a href="#" class="navbar-brand">
						<small>
							<i class="fa fa-leaf"></i>
							Ace Admin &copy; swind
						</small>
					</a>

					<!-- /section:basics/navbar.layout.brand -->

					<!-- #section:basics/navbar.toggle -->

					<!-- /section:basics/navbar.toggle -->
				</div>

				<!-- #section:basics/navbar.dropdown -->
				<div class="navbar-buttons navbar-header pull-right" role="navigation">
					<ul class="nav ace-nav">
						<li class="grey">
							<a data-toggle="dropdown" class="dropdown-toggle" href="#">
								<i class="ace-icon fa fa-tasks"></i>
								<span class="badge badge-grey">4</span>
							</a>

							<ul class="dropdown-menu-right dropdown-navbar dropdown-menu dropdown-caret dropdown-close">
								<li class="dropdown-header">
									<i class="ace-icon fa fa-check"></i>
									4 Tasks to complete
								</li>

								<li>
									<a href="#">
										<span class="clearfix">
											<span class="pull-left">Software Update</span>
											<span class="pull-right">65%</span>
										</span>

										<span class="progress progress-mini">
											<span style="width:65%" class="progress-bar"></span>
										</span>
									</a>
								</li>

								<li>
									<a href="#">
										<span class="clearfix">
											<span class="pull-left">Hardware Upgrade</span>
											<span class="pull-right">35%</span>
										</span>

										<span class="progress progress-mini">
											<span style="width:35%" class="progress-bar progress-bar-danger"></span>
										</span>
									</a>
								</li>

								<li>
									<a href="#">
										<span class="clearfix">
											<span class="pull-left">Unit Testing</span>
											<span class="pull-right">15%</span>
										</span>

										<span class="progress progress-mini">
											<span style="width:15%" class="progress-bar progress-bar-warning"></span>
										</span>
									</a>
								</li>

								<li>
									<a href="#">
										<span class="clearfix">
											<span class="pull-left">Bug Fixes</span>
											<span class="pull-right">90%</span>
										</span>

										<span class="progress progress-mini progress-striped active">
											<span style="width:90%" class="progress-bar progress-bar-success"></span>
										</span>
									</a>
								</li>

								<li class="dropdown-footer">
									<a href="#">
										See tasks with details
										<i class="ace-icon fa fa-arrow-right"></i>
									</a>
								</li>
							</ul>
						</li>

						<li class="purple">
							<a data-toggle="dropdown" class="dropdown-toggle" href="#">
								<i class="ace-icon fa fa-bell icon-animated-bell"></i>
								<span class="badge badge-important">8</span>
							</a>

							<ul class="dropdown-menu-right dropdown-navbar navbar-pink dropdown-menu dropdown-caret dropdown-close">
								<li class="dropdown-header">
									<i class="ace-icon fa fa-exclamation-triangle"></i>
									8 Notifications
								</li>

								<li>
									<a href="#">
										<span class="clearfix">
											<span class="pull-left">
												<i class="btn btn-xs no-hover btn-pink fa fa-comment"></i>
												New Comments
											</span>
											<span class="pull-right badge badge-info">+12</span>
										</span>
									</a>
								</li>

								<li>
									<a href="#">
										<i class="btn btn-xs btn-primary fa fa-user"></i>
										Bob just signed up as an editor ...
									</a>
								</li>

								<li>
									<a href="#">
										<span class="clearfix">
											<span class="pull-left">
												<i class="btn btn-xs no-hover btn-success fa fa-shopping-cart"></i>
												New Orders
											</span>
											<span class="pull-right badge badge-success">+8</span>
										</span>
									</a>
								</li>

								<li>
									<a href="#">
										<span class="clearfix">
											<span class="pull-left">
												<i class="btn btn-xs no-hover btn-info fa fa-twitter"></i>
												Followers
											</span>
											<span class="pull-right badge badge-info">+11</span>
										</span>
									</a>
								</li>

								<li class="dropdown-footer">
									<a href="#">
										See all notifications
										<i class="ace-icon fa fa-arrow-right"></i>
									</a>
								</li>
							</ul>
						</li>

						<li class="green">
							<a data-toggle="dropdown" class="dropdown-toggle" href="#">
								<i class="ace-icon fa fa-envelope icon-animated-vertical"></i>
								<span class="badge badge-success">5</span>
							</a>

							<ul class="dropdown-menu-right dropdown-navbar dropdown-menu dropdown-caret dropdown-close">
								<li class="dropdown-header">
									<i class="ace-icon fa fa-envelope-o"></i>
									5 Messages
								</li>

								<li class="dropdown-content">
									<ul class="dropdown-menu dropdown-navbar">
										<li>
											<a href="#">
												<img src="<%=request.getContextPath()%>/static/assets/avatars/avatar.png" class="msg-photo" alt="Alex's Avatar" />
												<span class="msg-body">
													<span class="msg-title">
														<span class="blue">Alex:</span>
														Ciao sociis natoque penatibus et auctor ...
													</span>

													<span class="msg-time">
														<i class="ace-icon fa fa-clock-o"></i>
														<span>a moment ago</span>
													</span>
												</span>
											</a>
										</li>

										<li>
											<a href="#">
												<img src="<%=request.getContextPath()%>/static/assets/avatars/avatar3.png" class="msg-photo" alt="Susan's Avatar" />
												<span class="msg-body">
													<span class="msg-title">
														<span class="blue">Susan:</span>
														Vestibulum id ligula porta felis euismod ...
													</span>

													<span class="msg-time">
														<i class="ace-icon fa fa-clock-o"></i>
														<span>20 minutes ago</span>
													</span>
												</span>
											</a>
										</li>

										<li>
											<a href="#">
												<img src="<%=request.getContextPath()%>/static/assets/avatars/avatar4.png" class="msg-photo" alt="Bob's Avatar" />
												<span class="msg-body">
													<span class="msg-title">
														<span class="blue">Bob:</span>
														Nullam quis risus eget urna mollis ornare ...
													</span>

													<span class="msg-time">
														<i class="ace-icon fa fa-clock-o"></i>
														<span>3:15 pm</span>
													</span>
												</span>
											</a>
										</li>

										<li>
											<a href="#">
												<img src="<%=request.getContextPath()%>/static/assets/avatars/avatar2.png" class="msg-photo" alt="Kate's Avatar" />
												<span class="msg-body">
													<span class="msg-title">
														<span class="blue">Kate:</span>
														Ciao sociis natoque eget urna mollis ornare ...
													</span>

													<span class="msg-time">
														<i class="ace-icon fa fa-clock-o"></i>
														<span>1:33 pm</span>
													</span>
												</span>
											</a>
										</li>

										<li>
											<a href="#">
												<img src="<%=request.getContextPath()%>/static/assets/avatars/avatar5.png" class="msg-photo" alt="Fred's Avatar" />
												<span class="msg-body">
													<span class="msg-title">
														<span class="blue">Fred:</span>
														Vestibulum id penatibus et auctor  ...
													</span>

													<span class="msg-time">
														<i class="ace-icon fa fa-clock-o"></i>
														<span>10:09 am</span>
													</span>
												</span>
											</a>
										</li>
									</ul>
								</li>

								<li class="dropdown-footer">
									<a href="inbox.html">
										See all messages
										<i class="ace-icon fa fa-arrow-right"></i>
									</a>
								</li>
							</ul>
						</li>

						<!-- #section:basics/navbar.user_menu -->
						<li class="light-blue">
							<a data-toggle="dropdown" href="#" class="dropdown-toggle">
								<img class="nav-user-photo" src="<%=request.getContextPath()%>/static/assets/avatars/user.jpg" alt="Jason's Photo" />
								<span class="user-info">
									<small>Welcome,</small>
									${sessionScope.user.userName}
								</span>

								<i class="ace-icon fa fa-caret-down"></i>
							</a>

							<ul class="user-menu dropdown-menu-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close">
								<li>
									<a href="#">
										<i class="ace-icon fa fa-cog"></i>
										Settings
									</a>
								</li>

								<li>
									<a href="profile.html">
										<i class="ace-icon fa fa-user"></i>
										Profile
									</a>
								</li>

								<li class="divider"></li>

								<li>
									<a href="<%=request.getContextPath()%>/login/logout">
										<i class="ace-icon fa fa-power-off"></i>
										Logout
									</a>
								</li>
							</ul>
						</li>

						<!-- /section:basics/navbar.user_menu -->
					</ul>
				</div>

				<!-- /section:basics/navbar.dropdown -->
			</div><!-- /.navbar-container -->
		</div>

		<!-- /section:basics/navbar.layout -->
		<div class="main-container" id="main-container">
			<script type="text/javascript">
				try{ace.settings.check('main-container' , 'fixed')}catch(e){}
			</script>


			<!-- /section:basics/sidebar -->
			<div class="main-content">
				

				<!-- /section:basics/content.breadcrumbs -->
				<div class="page-content">
					<!-- #section:settings.box -->
					<div class="ace-settings-container" id="ace-settings-container">
						<div class="btn btn-app btn-xs btn-warning ace-settings-btn" id="ace-settings-btn">
							<i class="ace-icon fa fa-cog bigger-150"></i>
							时间
						</div>

						<div class="ace-settings-box clearfix" id="ace-settings-box">
							<div class="pull-left width-50">
								<!-- #section:settings.skins -->
								<div class="ace-settings-item">
									<div class="pull-left">
										<select id="skin-colorpicker" class="hide">
											<option data-skin="no-skin" value="#438EB9">#438EB9</option>
											<option data-skin="skin-1" value="#222A2D">#222A2D</option>
											<option data-skin="skin-2" value="#C6487E">#C6487E</option>
											<option data-skin="skin-3" value="#D0D0D0">#D0D0D0</option>
										</select>
									</div>
									<span>&nbsp; Choose Skin</span>
								</div>

								<!-- /section:settings.skins -->

								<!-- #section:settings.navbar -->
								<div class="ace-settings-item">
									<label id="begintime" class="lbl" for="ace-settings-navbar"> 开始时间:<span id="begintime"><fmt:formatDate value="${beginTime}" pattern="yyyy/MM/dd HH:mm:ss"/></span></label>
								</div>

								<div class="ace-settings-item">
									<label id="totaltime" class="lbl" for="ace-settings-navbar"> 考试时长:<span id="totaltime">${examTime} </span>min</label>
								</div>

								<div class="ace-settings-item">
									<label  class="lbl" for="ace-settings-navbar"> 剩余时间:<span id="restTime"></span></label>
								</div>
								
								<!-- /section:settings.rtl -->

								

								<!-- /section:settings.container -->
							</div><!-- /.pull-left -->

							<div class="pull-left width-50">
								<!-- #section:basics/sidebar.options -->
								

								<!-- /section:basics/sidebar.options -->
							</div><!-- /.pull-left -->
						</div><!-- /.ace-settings-box -->
					</div><!-- /.ace-settings-container -->

					<!-- /section:settings.box -->
					<div class="page-content-area">
						<div class="page-header">
							<h1>
								在线考试
							</h1>
						</div><!-- /.page-header -->

						<div class="row">
							<div class="col-xs-12">
								<!-- PAGE CONTENT BEGINS -->
								<div class="row">
									<div class="col-xs-12">
										
				<!-- 单选题				<div class="control-group">
												<label class="control-label bolder blue">Checkbox</label>

												#section:custom/checkbox
												<div class="checkbox">
													<label>
														<input name="form-field-checkbox" class="ace" type="checkbox">
														<span class="lbl"> choice 1</span>
													</label>
												</div>

												<div class="checkbox">
													<label>
														<input name="form-field-checkbox" class="ace" type="checkbox">
														<span class="lbl"> choice 2</span>
													</label>
												</div>

												<div class="checkbox">
													<label>
														<input name="form-field-checkbox" class="ace ace-checkbox-2" type="checkbox">
														<span class="lbl"> choice 3</span>
													</label>
												</div>

												<div class="checkbox">
													<label class="block">
														<input name="form-field-checkbox" disabled="" class="ace" type="checkbox">
														<span class="lbl"> disabled</span>
													</label>
												</div>

												/section:custom/checkbox
											</div> -->
										
			<!-- 		多选题				<div class="control-group">
												<label class="control-label bolder blue">Radio</label>

												<div class="radio">
													<label>
														<input name="form-field-radio" class="ace" type="radio">
														<span class="lbl"> radio option 1</span>
													</label>
												</div>

												<div class="radio">
													<label>
														<input name="form-field-radio" class="ace" type="radio">
														<span class="lbl"> radio option 2</span>
													</label>
												</div>

												<div class="radio">
													<label>
														<input name="form-field-radio" class="ace" type="radio">
														<span class="lbl"> radio option 3</span>
													</label>
												</div>

												<div class="radio">
													<label>
														<input name="form-field-radio" disabled="" class="ace" type="radio">
														<span class="lbl"> disabled</span>
													</label>
												</div>
											</div> -->
										
										<h2>一、单选题（每题1分）</h2>
										<div id="singleSelect" style="margin-left: 100px;">
											<c:forEach items="${testList}" var="test" varStatus="status">
												<c:choose>
												<c:when test="${test.testTypeVo.id==1 }">
													<div class="control-group">
														<label class="control-label bolder blue">${status.count}.${test.content}</label>
		
														<div class="radio">
															<label>
																<input onchange="saveTestAjax()" value="a" name="${test.id }_choose" class="ace" type="radio">
																<span class="lbl"> ${test.chooseA}</span>
															</label>
														</div>
		
														<div class="radio">
															<label>
																<input onchange="saveTestAjax()" value="b" name="${test.id }_choose" class="ace" type="radio">
																<span class="lbl"> ${test.chooseB}</span>
															</label>
														</div>
		
														<div class="radio">
															<label>
																<input onchange="saveTestAjax()" value="c" name="${test.id }_choose" class="ace" type="radio">
																<span class="lbl"> ${test.chooseC}</span>
															</label>
														</div>
		
														<div class="radio">
															<label>
																<input onchange="saveTestAjax()" value="d" name="${test.id }_choose" class="ace" type="radio">
																<span class="lbl"> ${test.chooseD}</span>
															</label>
														</div>
													</div>
												</c:when>	
												</c:choose>
											</c:forEach>
										</div>
										
										<br><br>
										
										<h2>二、多选题（每题2分）</h2>
										<div id="multiSelect" style="margin-left: 100px;">
											<c:forEach items="${testList}" var="test" varStatus="status">
												<c:choose>
													<c:when test="${test.testTypeVo.id==2 }">
														<div class="control-group">
															<label class="control-label bolder blue">${status.count}.${test.content}</label>
			
															
															<div class="checkbox">
																<label>
																	<input onchange="saveTestAjax()" value="a" name="${test.id }_choose_multi" class="ace ace-checkbox-2" type="checkbox">
																	<span class="lbl"> ${test.chooseA}</span>
																</label>
															</div>
			
															<div class="checkbox">
																<label>
																	<input onchange="saveTestAjax()" value="b" name="${test.id }_choose_multi" class="ace ace-checkbox-2" type="checkbox">
																	<span class="lbl"> ${test.chooseB}</span>
																</label>
															</div>
			
															<div class="checkbox">
																<label>
																	<input onchange="saveTestAjax()" value="c" name="${test.id }_choose_multi" class="ace ace-checkbox-2" type="checkbox">
																	<span class="lbl"> ${test.chooseC}</span>
																</label>
															</div>
			
															<div class="checkbox">
																<label>
																	<input onchange="saveTestAjax()" value="d" name="${test.id }_choose_multi" class="ace ace-checkbox-2" type="checkbox">
																	<span class="lbl"> ${test.chooseD}</span>
																</label>
															</div>
														</div>
													</c:when>
												</c:choose>
											</c:forEach>
										</div>
										
										
										<%-- <table id="testtable" class="table table-striped table-bordered table-hover">
											<thead>
												<tr>
													<th>题号</th>
													<th>题型</th>
													<th>题目</th>
													<th>选项A</th>
													<th>选项B</th>
													<th>选项C</th>
													<th>选项D</th>
													<th>操作</th>
													
												</tr>
											</thead>

											<tbody>
												<c:forEach items="${testList}" var="test">
													<tr >
														<td>${test.id }</td>
														<td>${test.testTypeVo.testType }</td>
														<td>${test.content }</td>
														<c:choose>
															<c:when test="${test.testTypeVo.id==1 }">
																<td onclick="checkRadio(this)"><input value="a" type="radio" name="${test.id }_choose"/>${test.chooseA}</td>
																<td onclick="checkRadio(this)"><input value="b" type="radio" name="${test.id }_choose"/>${test.chooseB}</td>
																<td onclick="checkRadio(this)"><input value="c" type="radio" name="${test.id }_choose"/>${test.chooseC}</td>
																<td onclick="checkRadio(this)"><input value="d" type="radio" name="${test.id }_choose"/>${test.chooseD}</td>	
															</c:when>
															<c:when test="${test.testTypeVo.id==2 }">
																<td onclick="checkBox(this)"><input value="a" type="checkbox" name="${test.id }_choose_multi"/>${test.chooseA}</td>
																<td onclick="checkBox(this)"><input value="b" type="checkbox" name="${test.id }_choose_multi"/>${test.chooseB}</td>
																<td onclick="checkBox(this)"><input value="c" type="checkbox" name="${test.id }_choose_multi"/>${test.chooseC}</td>
																<td onclick="checkBox(this)"><input value="d" type="checkbox" name="${test.id }_choose_multi"/>${test.chooseD}</td>	
															</c:when>															
														</c:choose>
														<td >null</td>
													</tr>
												</c:forEach>
											</tbody>
											
											
										</table> --%>
										
										<br><br>
										
										<!-- <input onclick="saveTestAjax()" class="btn btn-primary btn-lg" type="button" value="save"/> -->
										<input onclick="submitTestAjax()" class="btn btn-primary btn-lg" type="button" value="交卷"/>
									</div><!-- /.span -->
								</div><!-- /.row -->
								
								
								
						</div><!-- /.row -->
					</div><!-- /.page-content-area -->
				</div><!-- /.page-content -->
			</div><!-- /.main-content -->

			<div class="footer">
				<div class="footer-inner">
					<!-- #section:basics/footer -->
					<div class="footer-content">
						<span class="bigger-120">
							<span class="blue bolder">Ace</span>
							Application &copy; 2013-2014
						</span>

						&nbsp; &nbsp;
						<span class="action-buttons">
							<a href="#">
								<i class="ace-icon fa fa-twitter-square light-blue bigger-150"></i>
							</a>

							<a href="#">
								<i class="ace-icon fa fa-facebook-square text-primary bigger-150"></i>
							</a>

							<a href="#">
								<i class="ace-icon fa fa-rss-square orange bigger-150"></i>
							</a>
						</span>
					</div>

					<!-- /section:basics/footer -->
				</div>
			</div>

			<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
				<i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
			</a>
		</div><!-- /.main-container -->
		
		</div>
		
		<!-- basic scripts -->

		<!--[if !IE]> -->
		<script type="text/javascript">
			window.jQuery || document.write("<script src='<%=request.getContextPath()%>/static/assets/js/jquery.min.js'>"+"<"+"/script>");
		</script>

		
		<!-- jqprint -->
		<script src="<%=request.getContextPath()%>/static/jqprint/jquery-migrate-1.4.1.min.js"></script>
		<%-- <script src="<%=request.getContextPath()%>/static/jqprint/jquery-1.4.4.min.js"></script> --%>
		<script src="<%=request.getContextPath()%>/static/jqprint/jquery.jqprint-0.3.js"></script>
	

		<!-- <![endif]-->

		<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='<%=request.getContextPath()%>/static/assets/js/jquery1x.min.js'>"+"<"+"/script>");
</script>
<![endif]-->
		<script type="text/javascript">
			if('ontouchstart' in document.documentElement) document.write("<script src='<%=request.getContextPath()%>/static/assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
		</script>
		<script src="<%=request.getContextPath()%>/static/assets/js/bootstrap.min.js"></script>

		<!-- page specific plugin scripts -->
		<script src="<%=request.getContextPath()%>/static/assets/js/jquery.dataTables.min.js"></script>
		<script src="<%=request.getContextPath()%>/static/assets/js/jquery.dataTables.bootstrap.js"></script>

		<!-- ace scripts -->
		<script src="<%=request.getContextPath()%>/static/assets/js/ace-elements.min.js"></script>
		<script src="<%=request.getContextPath()%>/static/assets/js/ace.min.js"></script>

		<!-- inline scripts related to this page -->
		<script type="text/javascript">
			jQuery(function($) {
				var oTable1 = 
				$('#sample-table-2')
				//.wrap("<div class='dataTables_borderWrap' />")   //if you are applying horizontal scrolling (sScrollX)
				.dataTable( {
					bAutoWidth: false,
					"aoColumns": [
					  { "bSortable": false },
					  null, null,null, null, null,
					  { "bSortable": false }
					],
					"aaSorting": [],
			
					//,
					//"sScrollY": "200px",
					//"bPaginate": false,
			
					//"sScrollX": "100%",
					//"sScrollXInner": "120%",
					//"bScrollCollapse": true,
					//Note: if you are applying horizontal scrolling (sScrollX) on a ".table-bordered"
					//you may want to wrap the table inside a "div.dataTables_borderWrap" element
			
					//"iDisplayLength": 50
			    } );
				/**
				var tableTools = new $.fn.dataTable.TableTools( oTable1, {
					"sSwfPath": "<%=request.getContextPath()%>/static/<%=request.getContextPath()%>/static/copy_csv_xls_pdf.swf",
			        "buttons": [
			            "copy",
			            "csv",
			            "xls",
						"pdf",
			            "print"
			        ]
			    } );
			    $( tableTools.fnContainer() ).insertBefore('#sample-table-2');
				*/
			
			
				$(document).on('click', 'th input:checkbox' , function(){
					var that = this;
					$(this).closest('table').find('tr > td:first-child input:checkbox')
					.each(function(){
						this.checked = that.checked;
						$(this).closest('tr').toggleClass('selected');
					});
				});
			
			
				$('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
				function tooltip_placement(context, source) {
					var $source = $(source);
					var $parent = $source.closest('table')
					var off1 = $parent.offset();
					var w1 = $parent.width();
			
					var off2 = $source.offset();
					//var w2 = $source.width();
			
					if( parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2) ) return 'right';
					return 'left';
				}
				
			
			})
		</script>

		<%-- <!-- the following scripts are used in demo only for onpage help and you don't need them -->
		<link rel="stylesheet" href="<%=request.getContextPath()%>/static/assets/css/ace.onpage-help.css" />
		<link rel="stylesheet" href="<%=request.getContextPath()%>/static/docs/assets/js/themes/sunburst.css" /> --%>

		<script type="text/javascript"> ace.vars['base'] = '..'; </script>
		<script src="<%=request.getContextPath()%>/static/assets/js/ace/elements.onpage-help.js"></script>
		<script src="<%=request.getContextPath()%>/static/assets/js/ace/ace.onpage-help.js"></script>
		<script src="<%=request.getContextPath()%>/static/docs/assets/js/rainbow.js"></script>
		<script src="<%=request.getContextPath()%>/static/docs/assets/js/language/generic.js"></script>
		<script src="<%=request.getContextPath()%>/static/docs/assets/js/language/html.js"></script>
		<script src="<%=request.getContextPath()%>/static/docs/assets/js/language/css.js"></script>
		<script src="<%=request.getContextPath()%>/static/docs/assets/js/language/javascript.js"></script>
	
		
		<script type="text/javascript">
			
			<%-- function checkRadio(obj){
				//var radio = $(obj).find("input[type='radio']");
				//alert($("obj input[type='radio']").name);
				$(obj).find("input[type='radio']").attr('checked',true); 
			}
			
			function checkBox(obj){
				$(obj).find("input[type='checkbox']").attr('checked',true);
			}
			--%>
			
			function saveTestAjax(){
				var idArr = new Array();
				var answerArr = new Array();
				var idArrMulti = new Array();
				var answerArrMulti = new Array();
				var arr = $("#singleSelect input[type='radio']:checked");
				for(var i=0;i<arr.length;i++){
					var radio = arr[i];
					var checkedNum = radio.name.split("_")[0];
					/* alert(arr[i].name); */
					idArr.push(checkedNum);
					answerArr.push(radio.value);
					//alert();
				}
				var multiArr = [];//多选题目
				var arr2 = $("#multiSelect input[type='checkbox']:checked");
				for(var i=0;i<arr2.length;i++){
					if(multiArr.indexOf(arr2[i].name)<0){
						multiArr.push(arr2[i].name);
					}
				}
				for(var i=0;i<multiArr.length;i++){
					idArrMulti.push(multiArr[i].split("_")[0]);
					var answer = $("#multiSelect input[type='checkbox'][name='"+multiArr[i]+"']:checked");
					if(answer.length>1){
						var answerArr2 = [];
						var answerStr ;
						for(var j=0;j<answer.length;j++){
							answerArr2.push(answer[j].value);
							
						}
						answerStr = answerArr2.join(",");
						answerArrMulti.push(answerStr);
					}else{
						answerArrMulti.push(answer[0].value);
					}
				}
				
				//_choose_multi
				$.ajax({
					traditional: true,
					type: 'POST',
		            url: '<%=request.getContextPath()%>/stu/saveTest',
		            data: {
		            	"idArr":idArr,
		            	"answerArr":answerArr,
		            	"idArrMulti":idArrMulti,
		            	"answerArrMulti":answerArrMulti
		            },
		            dataType: "json",
		            success: function(data){
		            	/* alert('success'); */
		            }
		        });
			}

			
			function submitTestAjax(){
				var idArr = new Array();
				var answerArr = new Array();
				var idArrMulti = new Array();
				var answerArrMulti = new Array();
				var arr = $("#singleSelect input[type='radio']:checked");
				for(var i=0;i<arr.length;i++){
					var radio = arr[i];
					var checkedNum = radio.name.split("_")[0];
					/* alert(arr[i].name); */
					idArr.push(checkedNum);
					answerArr.push(radio.value);
					//alert();
				}
				var multiArr = [];//多选题目
				var arr2 = $("#multiSelect input[type='checkbox']:checked");
				for(var i=0;i<arr2.length;i++){
					if(multiArr.indexOf(arr2[i].name)<0){
						multiArr.push(arr2[i].name);
					}
				}
				for(var i=0;i<multiArr.length;i++){
					idArrMulti.push(multiArr[i].split("_")[0]);
					var answer = $("#multiSelect input[type='checkbox'][name='"+multiArr[i]+"']:checked");
					if(answer.length>1){
						var answerArr2 = [];
						var answerStr ;
						for(var j=0;j<answer.length;j++){
							answerArr2.push(answer[j].value);
							
						}
						answerStr = answerArr2.join(",");
						answerArrMulti.push(answerStr);
					}else{
						answerArrMulti.push(answer[0].value);
					}
				}
				
				//_choose_multi
				$.ajax({
					traditional: true,
					type: 'POST',
		            url: '<%=request.getContextPath()%>/stu/submitTest',
		            data: {
		            	"idArr":idArr,
		            	"answerArr":answerArr,
		            	"idArrMulti":idArrMulti,
		            	"answerArrMulti":answerArrMulti
		            },
		            dataType: "json",
		            success: function(data){
			            if(data==true){
		            	alert('成功交卷');
		            	window.location.href="<%=request.getContextPath()%>/stu/subshow"; 
			            }else if(data==false){
			            	alert('失败');
			            	window.location.href="<%=request.getContextPath()%>/stu/subshow"; 
				        }
		            },
		            /* error: function(data) {
		            	
                    }, */
		            
				});
			}
			
			var beginTime = new Date("<fmt:formatDate value="${beginTime}" pattern="yyyy/MM/dd HH:mm:ss"/>");
			var examTimeMin = parseInt("${examTime}");
			var now = new Date();
			/* var restHour;
			var restMinute;
			var restSecond;
			if((now.getSeconds()-beginTime.getSeconds())>0){
				restSecond = now.getSeconds()-beginTime.getSeconds();
			}else{
				restMinute-1;
				restSecond = 60-now.getSeconds()-beginTime.getSeconds();
			} */
			var rest =  now.getTime()-beginTime.getTime();
			var count =examTimeMin*60-Math.floor(rest/1000);
			
			setInterval(function(){
				if(count==0){
					alert("考试结束，即将提交试卷");
					submitTestAjax();
					clearInterval();
				}
				count--;
				var hour = Math.floor(count/3600);
				var minute = Math.floor((count-hour*3600)/60);
				var second = Math.floor(count%60);
				if(hour<10){
					hour = "0" + hour;
				}
				if(minute<10){
					minute = "0" + minute;
				}
				if(second<10){
					second = "0" + second;
				}
				
				$("#restTime").text(hour+":"+minute+":"+second);
				
				
				//alert(count++);
			}, 1000); 
			
			
		</script>
		
		<script type="text/javascript">
			 $(document).ready(function(){
				if("${answerMap}"=="{}"&&"${answerMapMulti}"=="{}"){
					return;
				}
				
				//alert("${answerMap}");
				//el表达式返回的map非对象形式 是个字符串 只能手动拆包
				var mapStr = "${answerMap}";
				var mapStrWithoutBracket = mapStr.substring(1,mapStr.length-1);
				mapStrWithoutBracket = mapStrWithoutBracket.replace(/\s+/g,"");
				var mapArr = mapStrWithoutBracket.split(",");
				for(var i = 0;i<mapArr.length;i++){
					var key = mapArr[i].split("=")[0];
					var val = mapArr[i].split("=")[1];
					$("#singleSelect input[type='radio'][name='"+key+"_choose'][value='"+val+"']").attr("checked",true);
				}
				
				
				//多选
				var mapStrMulti = "${answerMapMulti}";
				var mapStrWithoutBracketMulti = mapStrMulti.substring(1,mapStrMulti.length-1);
				//mapStrWithoutBracketMulti = mapStrWithoutBracketMulti.replace(/\s+/g,"");
				var mapArrMulti = mapStrWithoutBracketMulti.split(", ");
				for(var i = 0;i<mapArrMulti.length;i++){
					var key = mapArrMulti[i].split("=")[0];
					
					var val = mapArrMulti[i].split("=")[1];
					if(val.indexOf(",")){
						var valArr = val.split(",");
						for(var j=0;j<valArr.length;j++){
							$("#multiSelect input[type='checkbox'][name='"+key+"_choose_multi'][value='"+valArr[j]+"']").attr("checked",true);
						}
					}else{
						$("#multiSelect input[type='checkbox'][name='"+key+"_choose_multi'][value='"+valArr[j]+"']").attr("checked",true);
					}
					
					
				} 
				
				
				
			});
			


			
		</script>
		
		
	</body>
</html>
